package com.jiahe.yehua.task.scheduled;

import com.jiahe.common.rabbit.constant.MqConst;
import com.jiahe.common.rabbit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author 阿良
 * @version 1.0
 * @date 2021/9/12 20:54
 */
@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    /**
     *  //每天8点执行方法，就医提醒
     *    //cron表达式，设置执行间隔
     *
     * //每隔30秒执行一次0/30 * * * * ?
     */
    @Scheduled(cron = "0/30 * * * * ?")
    public void taskPatient() {
        System.out.println("30miao");
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,MqConst.ROUTING_TASK_8,"您的预约时间是今天");
    }
}
